<?php
//
//  VictoryCMS - Content managment system and framework.
//  Copyright (C) 2009  Lewis Gunsch
//
//  This file is part of VictoryCMS.
//  
//  VictoryCMS is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
//
//  VictoryCMS is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//  
//  You should have received a copy of the GNU General Public License
//  along with VictoryCMS.  If not, see <http://www.gnu.org/licenses/>.

/**
 * VictoryCMS - PreferencesManager
 * 
 * @license http://www.gnu.org/licenses/gpl.html
 * @author Lewis Gunsch
 * @package Deprecated
 */

/**
 * @deprecated This class will be removed in future versions!
 * 
 * This Class includes the functions necessary for displaying the
 * user account preferences manager of the Victory church web site.
 *
 * @package Deprecated
 **/
class PreferencesManager extends UserManager {

	public function __construct() {
		
		$this->personalUpdate = true;
	}
	
	/**
	 * This function returns the title of the DisplayablePage
	 * in a string.
	 *
	 * @return The title of the page
	 **/
	public function getTitle() {
		return "My Account";
	}


	/**
	 * This function returns the name of the DisplayablePage
	 * in a string.
	 *
	 * @return The name of the page.
	 **/
	public function getName() {
		return "Account Manager";
	}


	/**
	 * This function returns a short text description of a
	 * DisplayablePage in a string.
	 *
	 * @return A short description of the page
	 **/
	public function getDescription() {
		return "update my information and preferences";
	}


	/**
	 * This function returns a comma seperated list
	 * of describing keywords in a string.
	 *
	 * @return A comma seperated keyword string
	 **/
	public function getKeywords() {
		return "";
	}


	/**
	 * This function returns the css style sheet
	 * in a string for the page.
	 *
	 * @return The css stylesheet for the page in a string
	 */
	public function getHeaderInfo() {
		$html = "";
		$html .= '<link href="http://www.victoryrock.org/members/vcotr1style.css" rel="stylesheet" type="text/css">';
		$html .= '<script src="http://www.victoryrock.org/members/vcotr1javascript.js" type="text/javascript"></script>';
		return $html;
	}


	/**
	 * This method returns the minimum necessary permissions
	 * needed to be able to view this page.
	 *
	 * @return Permission a permission object with permission set.
	 **/
	public function getPagePermissionLevel() {
		
		return new Permission("General User");
	}


	/**
	 * This function returns the html content of the page in a string.
	 * The content should not contain the template, just the page container
	 * content. The current page parameter should be set to the relative page
	 * path calling this function.
	 *
	 * @param currentPage The current relative page path calling this function.
	 *
	 * @return A string containing the html page content
	 **/
	public function renderPage( $currentPage ) {
		
		$this->personalUpdate = true;
		
		$html = "";
		$html .= "<table class='gray' id='personal_update_table' border='1' align='center' cellpadding='3' ";
		$html .= "cellspacing='0' class='user_update_table'>\n";
		$html .= "<tr class='gray'><th  class='gray'align='center'>&nbsp;My Account&nbsp;</th></tr>\n";
		$html .= "<tr class='gray'><td class='gray'>\n";
		$html .= $this->postUserUpdaterForm( $currentPage, true );
		$html .= "</td></tr>";
		$html .= "</table>\n<hr>";

		return $html;
	}

	/**
	 * This function sends the password and username of a new user
	 * to their inbox. This does not check the  email post for
	 * spammer email's. That should be done elsewhere.
	 *
	 * @param password The password to be emailed.
	 */
	protected function sendPasswordEmail( $password ) {

		$subject = "Your username and password from Victory Church on the Rock Edmonton West";

		$to = $_POST[self::EMAIL];
		$from = "dale@victoryrock.org";

		$message = "
		<html>
		<head>
			<title>Your new username and password from Victory Church on the Rock Edmonton West</title>
		</head>
		<body>
				Your password has been updated. Please login at 
				<a href='http://www.victoryrock.org/members'>http://www.victoryrock.org/members</a>.
			</p>
			<ul>
				<li>User name: ". $_POST[self::USER_POST] ."</li>
				<li>Password:  $password </li>
			</ul>
			<p>
				<em>Victory Church on the Rock Web Administration</em>
			</p>
		</body>
		</html>
		";

		// don't need anymore
		//$message = wordwrap( $message, 70 );

		// Always set content-type when sending HTML email
		$headers = "MIME-Version: 1.0" . "\r\n";
		$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
		$headers .= 'From: <'.$from.'>' . "\r\n";
		$headers .= 'Cc: ' . "\r\n";

		mail($to, $subject, $message, $headers);


		return;
	}

}

?>